.TH std::default_sentinel_t,std::default_sentinel 3 "2024.06.10" "http://cppreference.com" "C++ Standard Libary"
.SH NAME
std::default_sentinel_t,std::default_sentinel \- std::default_sentinel_t,std::default_sentinel

.SH Synopsis
   Defined in header <iterator>
   struct default_sentinel_t {};                           \fB(1)\fP \fI(since C++20)\fP
   inline constexpr default_sentinel_t default_sentinel{}; \fB(2)\fP \fI(since C++20)\fP

   1) default_sentinel_t is an empty class type used to denote the end of a range. It
   can be used together with iterator types that know the bound of their range (e.g.,
   std::counted_iterator).
   2) default_sentinel is a constant of type default_sentinel_t.

.SH Example


// Run this code

 #include <algorithm>
 #include <iostream>
 #include <iterator>
 #include <list>

 int main()
 {
     std::list<int> l{3, 1, 4, 1, 5, 9, 2, 6};

     std::ranges::copy(std::counted_iterator(std::begin(l), 4),
         std::default_sentinel, std::ostream_iterator<int>{std::cout, " "});
     std::cout << '\\n';
 }

.SH Output:

 3 1 4 1

.SH See also

   istream_iterator    input iterator that reads from std::basic_istream
                       \fI(class template)\fP
   istreambuf_iterator input iterator that reads from std::basic_streambuf
                       \fI(class template)\fP
   counted_iterator    iterator adaptor that tracks the distance to the end of the
   (C++20)             range
                       \fI(class template)\fP
